package com.xbs.service.hitchhiking;
/**
 * 前台顺风车的首页管理
 */
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import com.xbs.dao.hitchhiking.HitchDao;
import com.xbs.entity.CarModelEntity;
import com.xbs.entity.CityEntity;
import com.xbs.entity.HitchEntity;


public class HitchService {
	
private  HitchDao hitchdao;
	
	public HitchService() {
		hitchdao = new HitchDao();
		
	}
	
	
	/**
	 * 1.查询城市
	 */
	public List<CityEntity> getCity(String citys){		
		return hitchdao.getSomeCity(citys);	
	}
	
	/**
	 * 2.查询车的品牌
	 */
	public List<CarModelEntity> getCar(){
		return hitchdao.getHitchByType();
	}
	
	/**
	 * 3.根据城市，车型，时间查询不同的顺风车
	 */
	public List<HitchEntity> getHitch(String cityid,String cartype,String time){
		//sql语句拼接
		String select = "";
		if(cityid!=""){
			select += " and s.store_city ='"+cityid+"'";
		}
		if(cartype!=""){
			select += " and cm.car_model_name ='"+cartype+"'";
		}
		if(time!=""){
			select += " and hc.hitch_time<='"+time+"'";
		}
	
		return hitchdao.getHitch(select);
	}
	
	/**
	 * 4. 根据车型，起始门店和还车门店填订单
	 */
	public List<HitchEntity> getCarToOrder(String cartype,String ssname,String esname){
		//sql语句拼接
				String select = "";
				if(cartype!=""){
					select += " and cm.car_model_name ='"+cartype+"'";
				}
				if(ssname!=""){
					select += " and s.store_city ='"+ssname+"'";
				}
				if(esname!=""){
					select += " and s2.store_city ='"+esname+"'";
				}

				return hitchdao.getHitch(select);
	}
	
	
}
